import React, { useEffect } from 'react';
import { withRouter } from 'umi';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import PageRouter from '@/components/PageRouter/PageRouter';
import { eventTrack } from '@/utils/track';
import EntryHistoryList from './EntryHistoryList';
import WaitEntryList from './WaitEntryList';
// 入职管理-入口
const index = ({ location }) => {
    const { pathname } = location;
    const renderPage = () => {
        // 根据不同路由切换组件
        const pageMap = {
            '/office/personnelManagement/onboardAndLeave/entryManage/waitEntry': <WaitEntryList />,
            '/office/personnelManagement/onboardAndLeave/entryManage/entryHistory': <EntryHistoryList />
        };
        return pageMap[pathname] || null;
    };
    // eslint-disable-next-line react-hooks/rules-of-hooks
    useEffect(() => {
        eventTrack({
            eventName: 'personnel_management_onboard_and_leave_entry_manage_click',
            pageName: 'personnel_management_onboard_and_leave'
        });
    }, []);
    return (
        <PageHeaderWrapper>
            <PageRouter activePath={pathname} type="entryManage">
                {renderPage()}
            </PageRouter>
        </PageHeaderWrapper>
    );
};

export default withRouter(index);
